#ifndef PARTICLEEMITTER_H
#define PARTICLEEMITTER_H

#include "ParticlePrereq.h"

namespace ParticleDefines
{
	struct Vertex
	{
		Vector3 position;
		Vector2 texturecoord;
	};
}

class Camera;
class Particle;
class SceneManager;
class RenderSystem;
class ResourceManager;
class ParticleRenderer;
class ParticleEmitter
{
public:
	ParticleEmitter(ResourceManager* resource_manager, RenderSystem* render_system, ParticleRenderer* particle_renderer);
	~ParticleEmitter(void);

	bool Init(const Vector3& start_position, float emission_rate = 0.5f, unsigned int max_vertices = 1024);
	void Shut();
	void Update(float deltatime, Camera* camera);
	void SetParticleType(EParticleType particle_type) { m_type = particle_type; };

private:
	Particle* CreateParticle(const Vector3& start_position, const Vector3& direction, float lifetime);

	SceneObject* m_scene_object;

	SceneManager* m_scene_manager;
	ParticleRenderer* m_particle_renderer;
	ResourceManager* m_resource_manager;
	RenderSystem* m_render_system;


	float m_emission_rate;
	float m_current_time;
	Vector3 m_position;

	std::vector<class Particle*> m_particles;

	struct
	{
		Shader* m_shader;
		Texture* m_texture;
		Renderable m_renderable;
		unsigned int m_max_vertices;
		ParticleDefines::Vertex* m_vertices;
	} m_object;

	RasterizerState m_rasterizer;
	BlendState m_blend_state;
	DepthState m_depth_state;

	EParticleType m_type;
};

#endif